package com.fsy.dpclass.controller;

import com.fsy.dpclass.*;
import com.fsy.dpclass.service.BaseService;

/**
 * Created by Administrator on 2017/6/26.
 */
public class controller {

    public static void main(String[] args){
        String beanType = "B";
        BaseService baseService = getBaseSerivice(beanType);

        String beanName = baseService.sayBeanName();
        String name = baseService.sayName();
        String function = baseService.sayFunction();

        System.out.println(" beanName===>>>" +beanName );
        System.out.println("name ===>>>" + name);
        System.out.println("function ===>>>" + function);
    }

    private static BaseService getBaseSerivice(String beanType) {
        BaseService baseService = null;
        try {
            Class c = BaseEnum.getClassImpl(beanType + "Serice");
            assert c != null;
            baseService = (BaseService) c.newInstance();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        }
        return baseService;
    }
}
